package cn.javass.struts2impl.hello.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorldAction1 extends ActionSupport {
    private String account;
    private String password;
    private String submitFlag;
    private String[] habits;
    
    public String execute() throws Exception {
        // 1:收集参数
        // 2:组织参数
        // 3:调用模型的逻辑功能处理
        System.out.println("用户输入的参数为====" + "account=" + account + ",passsword=" + password + ",submitFlag=" + submitFlag);
        // 4:根据逻辑处理的结果来选择下一个页面
        return "toWelcome";
    }
    
    public void validate() {
        if(account==null || account.trim().length()==0){
            this.addFieldError("account", "账号不允许为空");
        }
        if(password==null || password.trim().length()==0){
            this.addFieldError("password", "密码不允许为空");
        }
        if(password==null || password.trim().length()<6){
            this.addFieldError("password", "密码长度必须在6位以上");
        }
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSubmitFlag() {
        return submitFlag;
    }

    public void setSubmitFlag(String submitFlag) {
        this.submitFlag = submitFlag;
    }

    public String[] getHabits() {
        return habits;
    }

    public void setHabits(String[] habits) {
        this.habits = habits;
    }
}
